from langchain_core.messages import HumanMessage, SystemMessage
from langchain_core.output_parsers import StrOutputParser
from langchain_openai import ChatOpenAI

model = ChatOpenAI(model="gpt-4o-mini")
messages = [SystemMessage(content="将以下内容从英语翻译成中⽂"), HumanMessage(content="Let's go for a run"), ]
parser = StrOutputParser()
# 使⽤Chains⽅式调⽤
chain = model | parser  # 等于 model.invoke() + parser.invoke()
response = chain.invoke(messages)
print(response)  # 我们去跑步吧
